﻿using System;
using System.Collections.Generic;
using System.Reflection;
using System.Linq;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Ue.CQRS.Tests")]

namespace Ue.CQRS.Events
{
    public class DomainEvent<TEventArgs> : IEvent
    {
        internal DomainEvent(string name, int level, TEventArgs eventArgs)
        {
            this.Id = Guid.NewGuid();
            this.Name = name;
            this.Level = level;
            this.EventArgs = eventArgs;
        }

        public Guid Id { get; private set; }

        public string Name { get; private set; }

        public int Level { get; private set; }

        public TEventArgs EventArgs { get; private set; }

        #region IEvent

        object IEvent.EventArgs
        {
            get { return this.EventArgs; }
        }

        #endregion

        public static implicit operator TEventArgs(DomainEvent<TEventArgs> domainEvent)
        {
            return domainEvent.EventArgs;
        }
    }
}
